# $Id: PKGBUILD 79510 2012-11-06 11:58:12Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=pyicqt
pkgver=0.8.1.5
pkgrel=6
pkgdesc="jabber icq transport"
arch=(any)
url="http://code.google.com/p/pyicqt/"
license=('GPL')
backup=(etc/ejabberd/pyicq.xml)
depends=('python2' 'twisted')
source=(http://pyicqt.googlecode.com/files/pyicqt-$pkgver.tar.gz
	pyicq.rc
	config.xml
	pyicqt.service
	pyicqt.tmpfiles)
md5sums=('d1c544f82ed416bbe987a5e419820fa8'
         'f5a7a999253286c0cd2bc6552ee885cd'
         '150501a11601763ce4ef12eb5649ef2a'
         'c3cc068a208b176bf088df9dda9650ac'
         '7a9bec0597576753f87093759cf2a7d8')

build() {
  cd $srcdir

  # python2 fix
  for file in $(find . -name '*.py' -print); do
    sed -i 's_^#!.*/usr/bin/python_#!/usr/bin/python2_' $file
    sed -i 's_^#!.*/usr/bin/env.*python_#!/usr/bin/env python2_' $file
  done

  install -d -m0755 $pkgdir/usr/lib
  cp -r $pkgname-$pkgver $pkgdir/usr/lib
  mv $pkgdir/usr/lib/$pkgname-$pkgver $pkgdir/usr/lib/$pkgname
  install -d -m0755 $pkgdir/var/spool/pyicqt
  install -D -m0644 ./config.xml $pkgdir/etc/ejabberd/pyicq.xml
  mv $pkgdir/usr/lib/$pkgname/config_example.xml $pkgdir/etc/ejabberd/pyicq_example.xml
  ln -s ../../../etc/ejabberd/pyicq.xml $pkgdir/usr/lib/$pkgname/config.xml
  install -D -m0755 pyicq.rc $pkgdir/etc/rc.d/pyicqt

  install -Dm0644 $srcdir/$pkgname.service $pkgdir/usr/lib/systemd/system/$pkgname.service
  install -Dm0644 $srcdir/$pkgname.tmpfiles $pkgdir/usr/lib/tmpfiles.d/$pkgname.conf
}
